home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / etc / acpi / suspend.d / 55-down-interfaces.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2009-03-27  |  1.3 KB  |  47 lines

  1. #!/bin/sh
  2.  
  3. pccardctl eject
  4.  
  5. # Get rid of any currently running dhclients
  6. killall dhclient dhclient3 2>/dev/null
  7.  
  8. # First do all network interfaces that were brought up by ifupdown. These are
  9. # the only interfaces that we bring up on resume (the other ones are probably
  10. # managed by other tools, such as NetworkManager, and will be brought up
  11. # automatically). Due to logical interfaces, the interfaces that we pass to
  12. # ifdown are DIFFERENT than those that we pass to ifup, see Debian BTS #475002.
  13. IFDOWN_INTERFACES="`cat /var/run/network/ifstate | sed 's/=.*//'`"
  14. IFUP_INTERFACES="`cat /var/run/network/ifstate`"
  15.  
  16. must_control_interface()
  17. {
  18.   # Always skip lo
  19.   test "$1" = "lo" && return 1
  20.   for i in $SKIP_INTERFACES; do
  21.       # Skip if listed in $SKIP_INTERFACES
  22.       echo "$1" | grep -q "^$i" && return 1
  23.   done
  24.   return 0
  25. }
  26.  
  27.  
  28. # Shut down the interfaces (except lo, which can and should be kept up)
  29. for x in $IFDOWN_INTERFACES; do
  30.     if must_control_interface $x ; then
  31.         ifdown $x
  32.     fi
  33. done
  34.  
  35. # TODO:  Tell NetworkManager to shut down networking at this point
  36.  
  37. # Find the remaining running network interfaces...
  38. INTERFACES=`/sbin/ifconfig | awk '/^[^ ]+/ {print $1}'`
  39.  
  40. # And shut them down (except lo, which can and should be kept up)
  41. for x in $INTERFACES; do
  42.     if must_control_interface $x ; then
  43.       ifconfig $x down
  44.     fi
  45. done
  46.  
  47.